import request from '@/utils/request'

export default {
  getAccommodationList(searchModel) {
    let params = '&pageNo=' + searchModel.pageNo + '&pageSize=' + searchModel.pageSize
    params =
      searchModel.name === '' ||
      searchModel.name === null ||
      searchModel.name === undefined
        ? params
        : params + '&name=' + searchModel.name
    return request({
      url: '/accommodation/list?' + params,
      method: 'get'

      // params:{
      //   pageNo:searchModel.pageNo,
      //   pageSize:searchModel.pageSize,
      //   name:searchModel.name,
      // }
    })
  },
  addAccommodation(accommodation) {
    return request({
      url: '/accommodation/addAccommodation',
      method: 'post',
      data: accommodation
    })
  },
  updateAccommodation(accommodation) {
    return request({
      url: '/accommodation/updateAccommodation',
      // method: 'put',
      method: 'post',
      data: accommodation
    })
  },
  saveAccommodation(accommodation) {
    if (accommodation.accommodationId == null || accommodation.accommodationId === undefined) {
      return this.addAccommodation(accommodation)
    }
    return this.updateAccommodation(accommodation)
  },
  getAccommodationById(accommodationId) {
    return request({
      // url: '/accommodation/'+id,
      url: `/accommodation/getAccommodationById/${accommodationId}`,
      method: 'get'
    })
  },
  deleteById(accommodationId) {
    return request({
      url: `/accommodation/deleteAccommodationById`,
      method: 'delete',
      params: {
        deleteAccommodationId: accommodationId
      }
    })
  }

}
